package com.amnc.service;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.amnc.cattle.model.AbortionPO;
import com.amnc.cattle.model.BcsPO;
import com.amnc.cattle.model.BodyTemperaturePO;
import com.amnc.cattle.model.CalvingPO;
import com.amnc.cattle.model.ChangeGrpPO;
import com.amnc.cattle.model.DictionaryPO;
import com.amnc.cattle.model.DryPO;
import com.amnc.cattle.model.EntryAnimalsPO;
import com.amnc.cattle.model.EntryToParkingPO;
import com.amnc.cattle.model.ExitFromParkingPO;
import com.amnc.cattle.model.ExitPO;
import com.amnc.cattle.model.GeneticsDataPO;
import com.amnc.cattle.model.HeatPO;
import com.amnc.cattle.model.HeightPO;
import com.amnc.cattle.model.InsemiationPO;
import com.amnc.cattle.model.LogStallPO;
import com.amnc.cattle.model.MilkTestPO;
import com.amnc.cattle.model.MorphologicalClassificationsPO;
import com.amnc.cattle.model.NotInseminationPO;
import com.amnc.cattle.model.PDMinusPO;
import com.amnc.cattle.model.PDPlusPO;
import com.amnc.cattle.model.PDUnclearPO;
import com.amnc.cattle.model.WeightPO;
import com.amnc.common.dif.DIFSheet;
import com.amnc.common.dif.exception.DIFDataException;
import com.amnc.common.dif.exception.DIFDataPairParsingException;
import com.amnc.common.dif.exception.DIFKeywordException;
import com.amnc.common.dif.exception.DIFNumberPairInfoException;
import com.amnc.common.dif.exception.DIFStringFormatException;

/**
     * 
     */
public class ExcelReader {
	public File fileArtifact = null;
	private MilkTestPO milkTestPO = new MilkTestPO("1", "2", "3", "3", "3",
			"4", "4", "4", "2", "2");
	private BodyTemperaturePO bodyTemperaturePO = new BodyTemperaturePO("3",
			"3", "4", "32", "3");
	private HeatPO heatPO = new HeatPO("2", "2", "2", "2", "2", "2");
	private EntryToParkingPO entryToParkingPO = new EntryToParkingPO("2", "2",
			"22", "22", "2");
	private ExitPO exitPO = new ExitPO("2", "3", "3", "4", "4", "4", "5", "33",
			"3", "44", "44");
	private ExitFromParkingPO exitFromParkingPO = new ExitFromParkingPO("2",
			"2", "22", "22", "2");
	private ChangeGrpPO changeGrpPO = new ChangeGrpPO("2", "2", "22", "22",
			"2", "3");
	private NotInseminationPO notInseminationPO = new NotInseminationPO("2",
			"22", "22", "2", "3");
	private AbortionPO abortionPO = new AbortionPO();
	private InsemiationPO insemiationPO = new InsemiationPO("1", "2", "3", "3",
			"3", "4", "4", "4", "2");
	private CalvingPO calvingPO = new CalvingPO("3", "3", "4", "32", "23", "23");
	private PDMinusPO pd0po = new PDMinusPO("3", "3", "4", "32", "2");
	private PDUnclearPO pd01po = new PDUnclearPO("3", "3", "4", "32");
	private BcsPO bcsPO = new BcsPO("3", "3", "4", "32", "33");
	private MorphologicalClassificationsPO morphologicalClassificationsPO = new MorphologicalClassificationsPO(
			"1", "2", "3", "2", "3", "3", "3", "4", "4", "4", "2", "3", "2",
			"3", "3", "3", "4", "4", "4", "2", "3", "4", "4", "4", "2");
	private EntryAnimalsPO entryAnimalsPO = new EntryAnimalsPO("3", "4", "32",
			"23", "23", "3", "4", "32", "23", "23", "3", "4", "32", "23", "23",
			"3", "4", "32", "23", "23", "3", "4", "32", "23", "23", "2", "2",
			"3", "4", "5");
	// private DryPO dryPO=new DryPO(farmId, cowId, dryDate, grp, drugDry,
	// dryComment, removeTag);

	private HeightPO heightPO = new HeightPO("3", "3", "4", "32", "33");
	private PDPlusPO pdPlusPO = new PDPlusPO("3", "3", "4", "32", "33", "32");
	private DictionaryPO dictionaryPO = new DictionaryPO("3", "4", "32", "33",
			"e");
	private DryPO dryPO = new DryPO();
	private WeightPO weightPO = new WeightPO("3", "3", "4", "32", "33");

	private LogStallPO logStallPO = new LogStallPO("2", "32", "23", "23", "3",
			"4", "32", "3", "4", "32", "23");
	
	private GeneticsDataPO geneticsDataPO=new GeneticsDataPO();

	static DIFSheet sheet;

	public void open() throws DIFKeywordException, DIFDataPairParsingException,
			DIFNumberPairInfoException, DIFStringFormatException, IOException,
			ParseException {
		// InputStream inStream =
		// ClassLoader.getSystemResourceAsStream("logstall.dif");
		// File f = new
		// File("D:"+File.separator+"Data"+File.separator+"logstall"+File.separator+"logstall.dif");
		// File file = new
		// File("D:"+File.separator+"Data"+File.separator+"logstall"+File.separator+"logstall.dif");
		// fileArtifact = new
		// File("D:"+File.separator+"Data"+File.separator+"logstall"+File.separator+"logstall.dif.processing");

		// File file = new
		// File("D:"+File.separator+"Data"+File.separator+"pd0"+File.separator+"1妊检- - 2015-07-07 09-19.dif");
		// fileArtifact = new
		// File("D:"+File.separator+"Data"+File.separator+"pd0"+File.separator+"1妊检- - 2015-07-07 09-19.processing");

		// File file = new
		// File("D:"+File.separator+"Data"+File.separator+"pd01"+File.separator+"1妊检-+ - 2015-07-07 09-20.dif");
		// fileArtifact = new
		// File("D:"+File.separator+"Data"+File.separator+"pd01"+File.separator+"1妊检-+ - 2015-07-07 09-20.processing");
		
		 
//		 File file = new
//		 File("D:"+File.separator+"Data"+File.separator+"bodytemperature"+File.separator+"1体温 - 2015-07-08 14-56.dif");
//		 fileArtifact = new
//		 File("D:"+File.separator+"Data"+File.separator+"bodytemperature"+File.separator+"1体温 - 2015-07-08 14-56.processing");
//		
//		File file = new File("D:" + File.separator + "Data" + File.separator
//				+ "bcs" + File.separator + "1体况评分 - 2015-07-07 09-21.dif");
//		fileArtifact = new File("D:" + File.separator + "Data" + File.separator
//				+ "bcs" + File.separator
//				+ "1体况评分 - 2015-07-07 09-21.processing");
//
//		 File file = new
//		 File("D:"+File.separator+"Data"+File.separator+"abortion"+File.separator+"1流产 - 2015-06-30 18-32.dif");
//		 fileArtifact = new
//		 File("D:"+File.separator+"Data"+File.separator+"abortion"+File.separator+"1流产 - 2015-06-30 18-32.processing");
//		
		 File file = new
				 File("D:"+File.separator+"Data"+File.separator+"entry"+File.separator+"1入群 - 2015-07-07 09-33.dif");
		 fileArtifact = new
				 File("D:"+File.separator+"Data"+File.separator+"entry"+File.separator+"1入群 - 2015-07-07 09-33.processing");
		 

		// File file = new
		// File("D:"+File.separator+"Data"+File.separator+"height"+File.separator+"1体高 - 2015-07-08 14-49.dif");
		// fileArtifact = new
		// File("D:"+File.separator+"Data"+File.separator+"height"+File.separator+"1体高 - 2015-07-08 14-49.processing");
		//
		// File file = new
		// File("D:"+File.separator+"Data"+File.separator+"weight"+File.separator+"1体重 - 2015-07-08 14-51.dif");
		// fileArtifact = new
		// File("D:"+File.separator+"Data"+File.separator+"weight"+File.separator+"1体重 - 2015-07-08 14-51.processing");
		
		// File file = new
		// File("D:"+File.separator+"Data"+File.separator+"pd1"+File.separator+"1妊检+ - 2015-07-08 08-27.dif");
		// fileArtifact = new
		// File("D:"+File.separator+"Data"+File.separator+"pd1"+File.separator+"1妊检+ - 2015-07-08 08-27.processing");
		//

		// File file = new
		// File("D:"+File.separator+"Data"+File.separator+"pd0"+File.separator+"1体温 - 2015-07-07 09-06.dif");
		// fileArtifact = new
		// File("D:"+File.separator+"Data"+File.separator+"pd0"+File.separator+"1体温 - 2015-07-07 09-06.processing");

//		
//		 File file = new
//		 File("D:"+File.separator+"Data"+File.separator+"calving"+File.separator+"1产犊 - 2015-07-10 11-15.dif");
//		 fileArtifact = new
//		 File("D:"+File.separator+"Data"+File.separator+"calving"+File.separator+"1产犊 - 2015-07-10 11-15.processing");
//		
//		 File file = new
//				 File("D:"+File.separator+"Data"+File.separator+"changegroup"+File.separator+"1改变组别 - 2015-07-10 14-31.dif");
//		 fileArtifact = new
//				 File("D:"+File.separator+"Data"+File.separator+"changegroup"+File.separator+"1改变组别 - 2015-07-10 14-31.processing");
//		 
//		 File file = new
//				 File("D:"+File.separator+"Data"+File.separator+"dry"+File.separator+"1干奶 - 2015-07-10 10-43.dif");
//		 fileArtifact = new
//				 File("D:"+File.separator+"Data"+File.separator+"dry"+File.separator+"1干奶 - 2015-07-10 10-43.processing");
//		 
//		 File file = new
//				 File("D:"+File.separator+"Data"+File.separator+"entry"+File.separator+"1入群 - 2015-07-07 09-33.dif");
//		 fileArtifact = new
//				 File("D:"+File.separator+"Data"+File.separator+"entry"+File.separator+"1入群 - 2015-07-07 09-33.processing");
//		 
//		 File file = new
//				 File("D:"+File.separator+"Data"+File.separator+"parking"+File.separator+"1隔离 - 2015-07-10 10-29.dif");
//		 fileArtifact = new
//				 File("D:"+File.separator+"Data"+File.separator+"parking"+File.separator+"1隔离 - 2015-07-10 10-29.processing");
//		 
//		 File file = new
//				 File("D:"+File.separator+"Data"+File.separator+"exit"+File.separator+"1离群 - 2015-07-10 10-24.dif");
//		 fileArtifact = new
//				 File("D:"+File.separator+"Data"+File.separator+"exit"+File.separator+"1离群 - 2015-07-10 10-24.processing");
//		 
//		 File file = new
//				 File("D:"+File.separator+"Data"+File.separator+"exitfromparking"+File.separator+"1退出隔离 - 2015-07-07 09-11.dif");
//		 fileArtifact = new
//				 File("D:"+File.separator+"Data"+File.separator+"exitfromparking"+File.separator+"1退出隔离 - 2015-07-07 09-11.processing");
//		 
//		 File file = new
//				 File("D:"+File.separator+"Data"+File.separator+"insemination"+File.separator+"1输精 - 2015-07-07 09-15.dif");
//		 fileArtifact = new
//				 File("D:"+File.separator+"Data"+File.separator+"insemination"+File.separator+"1输精 - 2015-07-07 09-15.processing");
//		 
//		 File file = new
//				 File("D:"+File.separator+"Data"+File.separator+"pd0"+File.separator+"1妊检- - 2015-07-07 09-19.dif");
//		 fileArtifact = new
//				 File("D:"+File.separator+"Data"+File.separator+"pd0"+File.separator+"1妊检- - 2015-07-07 09-19.processing");
//		 
//		 File file = new
//				 File("D:"+File.separator+"Data"+File.separator+"pd01"+File.separator+"1妊检-+ - 2015-07-07 09-20.dif");
//		 fileArtifact = new
//				 File("D:"+File.separator+"Data"+File.separator+"pd01"+File.separator+"1妊检-+ - 2015-07-07 09-20.processing");
//		 
//		 File file = new
//				 File("D:"+File.separator+"Data"+File.separator+"pd1"+File.separator+"1妊检+ - 2015-07-08 08-27.dif");
//		 fileArtifact = new
//				 File("D:"+File.separator+"Data"+File.separator+"pd1"+File.separator+"1妊检+ - 2015-07-08 08-27.processing");
//		 
//		 File file = new
//				 File("D:"+File.separator+"Data"+File.separator+"genetic"+File.separator+"1遗传数据英文 - 2015-07-10 11-54.dif");
//		 fileArtifact = new
//				 File("D:"+File.separator+"Data"+File.separator+"genetic"+File.separator+"1遗传数据英文 - 2015-07-10 11-54.processing");
//		 
//		 File file = new
//				 File("D:"+File.separator+"Data"+File.separator+"logstall"+File.separator+"logstall__234_10.dif");
//		 fileArtifact = new
//				 File("D:"+File.separator+"Data"+File.separator+"logstall"+File.separator+"logstall__234_10.processing");
//		 
		fileArtifact.createNewFile();
		InputStream inputStream = new FileInputStream(file);

		sheet = new DIFSheet(inputStream);
		System.out.println(sheet);

	}

	// public String getFarmID() throws DIFKeywordException,
	// DIFDataPairParsingException, DIFNumberPairInfoException,
	// DIFStringFormatException, IOException, ParseException, DIFDataException{
	// InputStream inStream =
	// ClassLoader.getSystemResourceAsStream("farmID.dif");
	// sheet = new DIFSheet(inStream);
	// String farmid="";
	// String cellValue= sheet.getRow(2).getCell(1).getStringCellValue();
	// farmid=cellValue;
	// return farmid;
	// }
	//

	public static void getAndSendAbortion(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}

		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		System.out.println("������" + file.getName());
		for (int i = 2; i < rowsN; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			// 流产日期不能为空
			if (!"".equals(rows[3]) && rows[3] != null) {
				readExcel.abortionPO.setFarmId(rows[1].toString());
				readExcel.abortionPO.setCowId(rows[2].toString());
				readExcel.abortionPO.setDate(rows[3].toString());
				readExcel.abortionPO.setReason(rows[4].toString());
				readExcel.abortionPO.setComment(rows[5].toString());
				readExcel.abortionPO.setResponsibleName(rows[6].toString());
				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/abortion";
				SendData.sendAbortion(readExcel.abortionPO, url);
			}

		}

	}

	public static void getMilkTest(File file, int columnMax)
			throws DIFKeywordException, DIFDataPairParsingException,
			DIFNumberPairInfoException, DIFStringFormatException,
			ParseException, DIFDataException {
		ExcelReader readExcel = new ExcelReader();
		// ���ļ�

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		System.out.println("������" + file.getName());
		for (int i = 2; i < rowsN ; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.milkTestPO.setFarmId(rows[1].toString());
				readExcel.milkTestPO.setCowId(rows[2].toString());
				readExcel.milkTestPO.setMilkTestDate(rows[3]);
				readExcel.milkTestPO.setYield(rows[4].toString());
				readExcel.milkTestPO.setFat(rows[5].toString());
				readExcel.milkTestPO.setProtein(rows[6].toString());
				readExcel.milkTestPO.setLactose(rows[7].toString());
				readExcel.milkTestPO.setScc(rows[8].toString());
				readExcel.milkTestPO.setUrea(rows[9].toString());
				readExcel.milkTestPO.setResponsibleName(rows[10].toString());

				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/milktest";
				SendData.sendMilkTest(readExcel.milkTestPO, url);
			}
			
		}

	}

	public static void getBodyTemperature(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();
		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];

		int rowsN = sheet.getRows().size();
		for (int i = 3; i < rowsN; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.bodyTemperaturePO.setFarmId(rows[1].toString());
				readExcel.bodyTemperaturePO.setCowId(rows[2]);
				readExcel.bodyTemperaturePO.setDate(rows[3]);
				readExcel.bodyTemperaturePO.setTemperatureValue(rows[4]);
				readExcel.bodyTemperaturePO.setResponsibleName(rows[5]);

				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/bodytemperature";
				SendData.sendBodyTemperature(readExcel.bodyTemperaturePO, url);
				
			}
			
		}

	}

	public static void getAndSendHeat(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();
		// ���ļ�

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		System.out.println("������" + file.getName());
		for (int i = 2; i < rowsN ; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.heatPO.setFarmId(rows[1].toString());
				readExcel.heatPO.setCowId(rows[2].toString());
				readExcel.heatPO.setDate(rows[3]);
				readExcel.heatPO.setHeatSymptoms(rows[4]);
				readExcel.heatPO.setHeatComment(rows[5]);
				readExcel.heatPO.setResponsibleName(rows[6]);

				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/heat";
				SendData.sendHeat(readExcel.heatPO, url);
			}
			
		}

	}

	public static void getAndSendEntryToParking(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();
		// ���ļ�

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		System.out.println("������" + file.getName());
		for (int i = 2; i < rowsN; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.entryToParkingPO.setFarmId(rows[1].toString());
				readExcel.entryToParkingPO.setCowId(rows[2].toString());
				readExcel.entryToParkingPO.setDate(rows[3]);
				readExcel.entryToParkingPO.setEntryToParkingComment(rows[4]);
				readExcel.entryToParkingPO.setResponsibleName(rows[5]);
				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/entrytoparking";
				SendData.sendEntryToParking(readExcel.entryToParkingPO, url);
			}
			
		}

	}

	public static void getAndSendExitFromParking(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();
		// ���ļ�

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		for (int i = 2; i < rowsN; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.exitFromParkingPO.setFarmId(rows[1].toString());
				readExcel.exitFromParkingPO.setCowId(rows[2].toString());
				readExcel.exitFromParkingPO.setDate(rows[3]);
				readExcel.exitFromParkingPO.setExitFromParkComment(rows[4]);
				readExcel.exitFromParkingPO.setResponsibleName(rows[5]);
			
				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/exitfromparking";
				SendData.sendExitFromParking(readExcel.exitFromParkingPO, url);
			}
			
		}

	}

	public static void getAndSendExit(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		System.out.println("������" + file.getName());
		for (int i = 2; i < rowsN ; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.exitPO.setFarmId(rows[1].toString());
				readExcel.exitPO.setCowId(rows[2].toString());
				readExcel.exitPO.setDate(rows[3]);
				readExcel.exitPO.setExitReason(rows[4]);
				readExcel.exitPO.setTypeOfExit(rows[5]);
				readExcel.exitPO.setDestination(rows[6]);
				readExcel.exitPO.setExitWeight(rows[7]);
				readExcel.exitPO.setExitPrice(rows[8]);
				readExcel.exitPO.setExitDocument(rows[9]);
				readExcel.exitPO.setExitComment(rows[10]);
				readExcel.exitPO.setResponsibleName(rows[11]);

				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/exit";
				SendData.sendExit(readExcel.exitPO, url);
			}
			
		}

	}

	public static void getAndSendChangeGrp(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		for (int i = 2; i < rowsN; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.changeGrpPO.setFarmId(rows[1].toString());
				readExcel.changeGrpPO.setCowId(rows[2].toString());
				readExcel.changeGrpPO.setDate(rows[3]);
				readExcel.changeGrpPO.setNewGroup(rows[4]);
				readExcel.changeGrpPO.setChangeGroupComment(rows[5]);
				readExcel.changeGrpPO.setResponsibleName(rows[6]);
				/**
				 */
//				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/changegroup";
			String 	 url="http://localhost:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/changegroup";
				SendData.sendChangeGrp(readExcel.changeGrpPO, url);
			}
			
		}

	}


	public static void getAndSendNotInsemination(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();
		// ���ļ�

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		System.out.println("������" + file.getName());
		for (int i = 2; i < rowsN - 3; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.notInseminationPO.setFarmId(rows[1].toString());
				readExcel.notInseminationPO.setCowId(rows[2].toString());
				readExcel.notInseminationPO.setNotInseminationDate(rows[3]);
				readExcel.notInseminationPO.setNotInseminationComment(rows[4]);
				readExcel.notInseminationPO.setResponsibleName(rows[5]);

				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/notinsemination";
				SendData.sendNotInsemination(readExcel.notInseminationPO, url);
			}
			
		}

	}

	public static void getAndSendInsemination(File file, int columnMax)
			throws DIFKeywordException, DIFDataPairParsingException,
			DIFNumberPairInfoException, DIFStringFormatException,
			ParseException, DIFDataException {
		ExcelReader readExcel = new ExcelReader();
		// ���ļ�

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		System.out.println("������" + file.getName());
		for (int i = 2; i < rowsN ; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.insemiationPO.setFarmId(rows[1].toString());
				readExcel.insemiationPO.setCowId(rows[2].toString());
				readExcel.insemiationPO.setDate(rows[3]);
				readExcel.insemiationPO.setInseminatorName(rows[4]);
				readExcel.insemiationPO.setBullId(rows[5]);
				readExcel.insemiationPO.setBullName(rows[6]);
				readExcel.insemiationPO.setSemenAmount(rows[7]);
				readExcel.insemiationPO.setInsemComment(rows[8]);
				readExcel.insemiationPO.setTypeOfPortion(rows[9]);
				
				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/insemination";
				SendData.sendInsemination(readExcel.insemiationPO, url);
			}
			
		}
	}

	public static void getAndSendPd0(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		System.out.println("������" + file.getName());
		for (int i = 2; i < rowsN; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}
			
			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.pd0po.setFarmId(rows[1].toString());
				readExcel.pd0po.setCowId(rows[2].toString());
				readExcel.pd0po.setDate(rows[3]);
				readExcel.pd0po.setComment(rows[4]);

//				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/pd0";
				String url = "http://localhost:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/pd0";
				SendData.sendPd0(readExcel.pd0po, url);
			}
			
		}

	}

	public static void getAndSendPd01(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();
		// ���ļ�

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		for (int i = 2; i < rowsN; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.pd01po.setFarmId(rows[1].toString());
				readExcel.pd01po.setCowId(rows[2].toString());
				readExcel.pd01po.setDate(rows[3]);
				readExcel.pd01po.setComment(rows[4]);
				
//				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/unclearpd";
				String url = "http://localhost:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/unclearpd";
				SendData.sendPd01(readExcel.pd01po, url);
			}
			
		}

	}

	public static void getAndSendBcs(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		System.out.println("������" + file.getName());
		for (int i = 2; i <= rowsN - 1; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}
			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.bcsPO.setFarmId(rows[1].toString());
				readExcel.bcsPO.setCowId(rows[2].toString());
				readExcel.bcsPO.setBcsDate(rows[3]);
				readExcel.bcsPO.setLastBcs(rows[4]);
				readExcel.bcsPO.setResponsibleName(rows[5]);

				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/bcs";
//				String url = "http://localhost:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/bcs";
				SendData.sendBcs(readExcel.bcsPO, url);
				
			}
			
		}

	}

	public static void getAndSendMorphological(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();
		// ���ļ�

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		System.out.println("������" + file.getName());
		for (int i = 2; i < rowsN ; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.morphologicalClassificationsPO.setFarmId(rows[1]
						.toString());
				readExcel.morphologicalClassificationsPO.setCowId(rows[2]
						.toString());
				readExcel.morphologicalClassificationsPO.setDate(rows[3]);
				readExcel.morphologicalClassificationsPO.setFinalScore(rows[4]);
				readExcel.morphologicalClassificationsPO
						.setGeneralAppearance(rows[5]);
				readExcel.morphologicalClassificationsPO.setDairyCharacter(rows[6]);
				readExcel.morphologicalClassificationsPO.setBodyCapacity(rows[7]);
				readExcel.morphologicalClassificationsPO.setUdder(rows[8]);
				readExcel.morphologicalClassificationsPO.setStature(rows[9]);
				readExcel.morphologicalClassificationsPO.setStrength(rows[10]);
				readExcel.morphologicalClassificationsPO.setDepth(rows[11]);
				readExcel.morphologicalClassificationsPO.setAngularity(rows[12]);
				readExcel.morphologicalClassificationsPO.setAngleRump(rows[13]);
				readExcel.morphologicalClassificationsPO.setRumpWidth(rows[14]);
				readExcel.morphologicalClassificationsPO
						.setRearLegSideView(rows[15]);
				readExcel.morphologicalClassificationsPO.setViewRearLegs(rows[16]);
				readExcel.morphologicalClassificationsPO.setFootAngle(rows[17]);
				readExcel.morphologicalClassificationsPO.setFrontUdder(rows[18]);
				readExcel.morphologicalClassificationsPO
						.setRearUdderHeight(rows[19]);
				readExcel.morphologicalClassificationsPO
						.setRearUdderWidth(rows[20]);
				readExcel.morphologicalClassificationsPO.setUdderCleft(rows[21]);
				readExcel.morphologicalClassificationsPO.setUdderDepth(rows[22]);
				readExcel.morphologicalClassificationsPO.setTeatPlacement(rows[23]);
				readExcel.morphologicalClassificationsPO
						.setRearTeatPlacementt(rows[24]);
				readExcel.morphologicalClassificationsPO.setTeatSize(rows[25]);
				// readExcel.morphologicalClassificationsPO.setResponsibleName(rows[26]);

				String url = "http://localhost:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/morphological";
				SendData.sendMorphological(
						readExcel.morphologicalClassificationsPO, url);
				
			}
			
		}
	}

	public static void getAndSendDictionary(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();
		// ���ļ�

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}

		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		System.out.println("������" + file.getName());
		for (int i = 1; i < rowsN; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}


			readExcel.dictionaryPO.setCode(rows[1]);
			readExcel.dictionaryPO.setName(rows[2]);
			readExcel.dictionaryPO.setDescription(rows[3]);
			readExcel.dictionaryPO.setP_code_id(rows[4]);
			readExcel.dictionaryPO.setComment(rows[5]);

			String url = "http://localhost:8080/amnc-integration-afifarm-sandbox/event/dictionary";
			SendData.sendDictionary(readExcel.dictionaryPO, url);
		}

	}

	public static void getAndSendEntry(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();
		// ���ļ�

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		for (int i = 2; i < rowsN; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			if (!"".equals(rows[3]) && rows[3]!=null && !"".equals(rows[13]) && rows[13]!=null) {
				readExcel.entryAnimalsPO.setFarmId(rows[1]);
				readExcel.entryAnimalsPO.setCowId(rows[2]);
				readExcel.entryAnimalsPO.setDate(rows[3]);
				readExcel.entryAnimalsPO.setBreed(rows[4]);
				readExcel.entryAnimalsPO.setHerd(rows[5]);
				readExcel.entryAnimalsPO.setGrp(rows[6]);
				readExcel.entryAnimalsPO.setTypeOfEntry(rows[7]);
				readExcel.entryAnimalsPO.setEntryDocument(rows[8]);
				readExcel.entryAnimalsPO.setOrigin(rows[9]);
				readExcel.entryAnimalsPO.setRegistrationNo(rows[10]);
				readExcel.entryAnimalsPO.setHerdBookNo(rows[11]);
				readExcel.entryAnimalsPO.setName(rows[12]);
				readExcel.entryAnimalsPO.setBirthDate(rows[13]);
				readExcel.entryAnimalsPO.setSex(rows[14]);
				readExcel.entryAnimalsPO.setTag(rows[15]);
				readExcel.entryAnimalsPO.setPassiveTag(rows[16]);
				readExcel.entryAnimalsPO.setColor(rows[17]);
				readExcel.entryAnimalsPO.setEntryWeight(rows[18]);
				readExcel.entryAnimalsPO.setEntryPrice(rows[19]);
				readExcel.entryAnimalsPO.setEntryComment(rows[20]);
				readExcel.entryAnimalsPO.setOldId(rows[21]);
				readExcel.entryAnimalsPO.setDamNo(rows[22]);
				readExcel.entryAnimalsPO.setSireName(rows[23]);
				readExcel.entryAnimalsPO.setTypeOfStall(rows[24]);
				readExcel.entryAnimalsPO.setResponsibleName(rows[25]);

				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/entryanimals";
//				String url = "http://localhost:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/entryanimals";
				SendData.sendEntryAnimals(readExcel.entryAnimalsPO, url);
				
			}
			
		}

	}

	public static void getAndSendCalving(File file, int columnMax)
			throws DIFKeywordException, DIFDataPairParsingException,
			DIFNumberPairInfoException, DIFStringFormatException,
			ParseException, DIFDataException {
		ExcelReader readExcel = new ExcelReader();
		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
			System.out.println("  data is wrong");
		}

		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		System.out.println("������" + file.getName());
		for (int i = 2; i < rowsN; i++) {
			for (int j = 1; j <= rowsN; j++) {
				if (sheet.getRow(i).getCell(j)==null) 
					break;
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			if (!"".equals(rows[3]) &&  rows[3]!=null ) {
				readExcel.calvingPO.setFarmId(rows[1].toString());
				readExcel.calvingPO.setCowId(rows[2].toString());
				readExcel.calvingPO.setDate(rows[3]);
				readExcel.calvingPO.setCowGroup(rows[4]);
				readExcel.calvingPO.setTag(rows[5]);
				readExcel.calvingPO.setCalvingManner(rows[6]);
				
				String url = "http://localhost:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/calving";
//				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/calving";
				SendData.sendCalving(readExcel.calvingPO, url);
			}
			
		}

	}

	// a little difference from other in here
	public static void getAndSendLogStall(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		// get the farmID
		String farmId = "1";
		// try {
		// farmId = readExcel.getFarmID();
		// } catch (IOException e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// System.out.println("getting the farmid is wrong ");
		// }

		// difference
		String[] rows = new String[columnMax + 2];
		int rowsN = sheet.getRows().size();

		for (int i = 2; i < rowsN ; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			readExcel.logStallPO.setCowId(rows[1].toString());
			readExcel.logStallPO.setTag(rows[2]);
			readExcel.logStallPO.setGrp(rows[3]);
			readExcel.logStallPO.setYield(rows[4]);
			readExcel.logStallPO.setAmt(rows[6]);
			readExcel.logStallPO.setCond(rows[7]);
			readExcel.logStallPO.setSteps(rows[9]);
			readExcel.logStallPO.setStall(rows[10]);

			readExcel.logStallPO.setFarmId(farmId);

			// 假定班次为 1
			readExcel.logStallPO.setSession("1");

			// 获取当天日期发送
			// 当遇到异常：停滞一天再发送时，或是第一次发送时，之前的日期则都被重置为今日-是漏洞
			SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
			String day = dateFormat.format(new Date());
			readExcel.logStallPO.setTime(day);

			// String
			// url="http://localhost:8080/RESTfulExample/rest/jsonServices/send";
			// String
			// url="http://localhost:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/logstall";
			String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/logstall";
			System.out.println("logstall");
			SendData.send(readExcel.logStallPO, url);

		}

		readExcel.fileArtifact.delete();

	}

	public static void getAndSendDry(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}

		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		for (int i = 2; i < rowsN ; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}
			
			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.dryPO.setFarmId(rows[1]);
				;
				readExcel.dryPO.setCowId(rows[2]);
				;
				readExcel.dryPO.setDate(rows[3]);
				readExcel.dryPO.setDrugDry(rows[4]);
				readExcel.dryPO.setDryComment(rows[5]);
				if ("".equals(rows[6]) || "--".equals(rows[6]) ) {
					readExcel.dryPO.setIsRemoveTag("1");
				}else {
					readExcel.dryPO.setIsRemoveTag("0");
				}
				String url = "http://localhost:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/dry";
//				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/dry";
				SendData.sendDry(readExcel.dryPO, url);
				
			}
			

		}

	}

	public static void getAndSendPd1(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		System.out.println("������" + file.getName());
		for (int i = 2; i < rowsN; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}
			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.pdPlusPO.setFarmId(rows[1].toString());
				readExcel.pdPlusPO.setCowId(rows[2].toString());
				readExcel.pdPlusPO.setVisitDate(rows[3]);
				readExcel.pdPlusPO.setPregDays(rows[4]);
				readExcel.pdPlusPO.setVet(rows[5]);
				readExcel.pdPlusPO.setVetComment(rows[6]);

				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/pd1";
				SendData.sendPd1(readExcel.pdPlusPO, url);
			}
			
		}

	}

	public static void getBodyHeight(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();
		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];

		int rowsN = sheet.getRows().size();
		for (int i = 3; i < rowsN; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.heightPO.setFarmId(rows[1].toString());
				readExcel.heightPO.setCowId(rows[2].toString());
				readExcel.heightPO.setDate(rows[3]);
				readExcel.heightPO.setHeightValue(rows[4]);
				readExcel.heightPO.setResponsibleName("");

				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/height";
				SendData.sendHeight(readExcel.heightPO, url);
			}
			
		}

	}

	public static void getBodyWeight(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();
		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] rows = new String[columnMax + 1];

		int rowsN = sheet.getRows().size();
		for (int i = 3; i < rowsN; i++) {
			for (int j = 1; j <= columnMax; j++) {
				String cellValue = sheet.getRow(i).getCell(j)
						.getStringCellValue();
				rows[j] = cellValue;
			}

			if (!"".equals(rows[3]) && rows[3]!=null) {
				readExcel.weightPO.setFarmId(rows[1].toString());
				readExcel.weightPO.setCowId(rows[2].toString());
				readExcel.weightPO.setDate(rows[3]);
				readExcel.weightPO.setWeightValue(rows[4]);
				readExcel.weightPO.setResponsibleName(rows[5]);

				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/weight";
				SendData.sendWeight(readExcel.weightPO, url);
			}
			
		}

	}
	
	public static void getAndSendGenetic(File file, int columnMax)
			throws DIFDataException, DIFKeywordException,
			DIFDataPairParsingException, DIFNumberPairInfoException,
			DIFStringFormatException, ParseException {
		ExcelReader readExcel = new ExcelReader();

		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
		}

		String[] rows = new String[columnMax + 1];
		int rowsN = sheet.getRows().size();
		for (int i = 2; i < rowsN; i++) {
			for (int j = 1; j <= columnMax; j++) {
				
				if (sheet.getRow(i).getCell(j)!=null && !"".equals(sheet.getRow(i).getCell(j))) {
					String cellValue = sheet.getRow(i).getCell(j)
							.getStringCellValue();
					rows[j] = cellValue;
				}
			}

			// 流产日期不能为空
			if (!"".equals(rows[3]) && rows[3] != null) {
				readExcel.geneticsDataPO.setFarmId(rows[2].toString());
				readExcel.geneticsDataPO.setCowId(rows[1].toString());
				readExcel.geneticsDataPO.setDate(rows[3].toString());
				readExcel.geneticsDataPO.setProteinPta(rows[4]);
				readExcel.geneticsDataPO.setProteinPtaPer(rows[5]);
				readExcel.geneticsDataPO.setFatPta(rows[6]);
				readExcel.geneticsDataPO.setFatPtaPer(rows[7]);
				readExcel.geneticsDataPO.setMilkPta(rows[8]);
				readExcel.geneticsDataPO.setRank(rows[9]);
				readExcel.geneticsDataPO.setTpi(rows[10]);
				readExcel.geneticsDataPO.setRPer(rows[11]);
				readExcel.geneticsDataPO.setTypePTA(rows[12]);
				readExcel.geneticsDataPO.setTypeRPer(rows[13]);
				readExcel.geneticsDataPO.setCompositesUdder(rows[14]);
				readExcel.geneticsDataPO.setResponsibleName(rows[15]);

//				String url = "http://192.168.1.2:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/geneticsdata";
				String url = "http://localhost:8080/amnc-integration-afifarm-1.0-SNAPSHOT/event/geneticsdata";
				SendData.sendGenetic(readExcel.geneticsDataPO, url);
			}

		}
		
		file.delete();

	}

	
	
	
	

}
